
<%@page import="classes.Reports"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
        <link rel="stylesheet" href="../css/table.css" type="text/css" />

        <title>Revenue By Stock</title>
    </head>
    <body>
        <table id="table-1">
	<thead>
                <th>Stock Type</th>
		<th>Revenue</th>
	</thead>
	<tbody>
	<%
            String query="SELECT T.StockID, SUM((S.PricePerShare-R.PricePerShare) * O.NumShares) AS Revenue"+
                    " FROM `brchung`.`stock` S, `brchung`.`transaction` R, `brchung`.`order1` O, `brchung`.`trade` T, `brchung`.`account` A"+
                    " WHERE T.TransactionID = R.ID AND T.StockID = S.StockSymbol AND T.AccountID = A.ID AND R.PricePerShare < S.PricePerShare AND T.OrderID = O.ID"+
                    " Group By T.StockID;";
            Reports.getConnection(query);
            ArrayList<String[]> rs=Reports.getResults(1,2);
            for(int i=0;i<rs.size();i++){
                out.print("<tr>");
                for(int j=0;j<2;j++)
                    out.print("<td>"+rs.get(i)[j]+"</td>");
                out.print("</tr>");
            }
        %>
	</tbody>
    </table>
    </body>
</html>
